#!/bin/sh
export TCGPATH=/root/tcg
SWTPMPATH=$TCGPATH/swTPM
TPMDEVPATH=$TCGPATH/tpmd_dev
sudo killall tpm_server
sudo killall tcsd
sudo rmmod tpmd_dev
export TPM_SERVER_PORT=$1
export TPM_SERVER_NAME=127.0.0.1
export TPM_PORT=$1
export TPM_PATH=$SWTPMPATH/tpmdata/$1
sudo rm -rf $SWTPMPATH/tpmdata/$1
mkdir -p $SWTPMPATH/tpmdata/$1
$SWTPMPATH/tpm/tpm_server &>tpm.log &
sleep 1
$SWTPMPATH/libtpm/utils/tpminit 
$SWTPMPATH/libtpm/utils/tpmbios 
sudo killall tpm_server
sleep 2
$SWTPMPATH/tpm/tpm_server &>tpm.log &
sleep 1
$SWTPMPATH/libtpm/utils/tpmbios 
sudo killall tcsd
sudo rmmod tpmd_dev.ko
cd $TPMDEVPATH
source ./load_tpmd_dev.sh $1
sudo tcsd
cd -
$SWTPMPATH/libtpm/utils/createek
./example/TESI_init -v 1.2
./example/TESI_test -v 1.2

